<template>
  <j-modal
    title="打印"
    :width="modalWidth"
    :visible="visible"
    :maskClosable="false"
    switchFullscreen
    @cancel="handleCancel">
    <template slot="footer">
      <a-button key="close" @click="handleCancel">
        关闭
      </a-button>
    </template>
    <iframe  :src="reportUrl" frameborder="0" scrolling="no" :height="printHeight" width="100%"> </iframe>
  </j-modal>
</template>

<script>

import { getReportPrintUrl } from '@/utils/util';

  export default {
    name: 'YqPrintModal',
    components: {
    },
    props:{
      reportId: {
        type: String,
        default: '',
        required: true
      },
      modalWidth: {
        type: Number,
        default: 1000,
        required: false
      },
      printHeight: {
        type: String,
        default: '700px',
        required: false
      }
    },
    data() {
      return {
        title:'',
        width:800,
        visible: false,
        disableSubmit: false,
        reportUrl:''
      }
    },
    methods:{
      print (id) {
        this.reportUrl = getReportPrintUrl(window._CONFIG['domianURL'].replace("/api","") + '/jmreport/view/' + this.reportId, id, false);
        this.visible=true
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      },
    }
  }
</script>

<style scoped>
</style>